package distributedbank.requests;
import java.io.IOException;
import distributedbank.server.BankBranch;
import distributedbank.Wrapper;

/**
 * Represents a request to deposit a certain amount of money to the given
 * account. This type of request is only sent as part of a TransferRequest.
 */
public class TransferDepositRequest extends Request {
    private int amount; // amount to transfer in cents
    /**
     * Note: the transactionId must be globally unique!
     */
    public TransferDepositRequest(int originatingBranchId, int branchId, int accountId,
                                  int transactionId, int amount) {
        super(branchId, accountId, transactionId);
        this.amount = amount;
    }
    public void runRequest(BankBranch bankBranch, Wrapper wrapper) 
                throws IOException {
        System.out.println("Transfering to account " +
                           this.accountId + " at branch " + this.branchId);
        bankBranch.getAccount(this.accountId).deposit(this.amount, this.transactionId);
        }
}
